package org.maiyodemo;


import javax.xml.ws.Endpoint;

import org.apache.cxf.jaxws.EndpointImpl;
import org.maiyodemo.interceptor.AuthInterceptor;
import org.maiyodemo.ws.MaiyoWs;
import org.maiyodemo.ws.MaiyoWsImpl;

public class Server {
	
	static String SERVER_PORT = "http://192.168.0.21/maiyo-demo-ws-server";
	
	/** 发布WebService
	Server() {
		System.out.println("Starting Server...");
		MaiyoWs ws = new MaiyoWsImpl();
		Endpoint.publish(SERVER_PORT, ws);
	} */
	
	/** 发布WebService，获取IN，OUT拦截器列表，并添加CXF自带的日志拦截器
	Server() {
		System.out.println("Starting Server...");
		MaiyoWs ws = new MaiyoWsImpl();
		EndpointImpl ep = (EndpointImpl) Endpoint.publish(SERVER_PORT, ws);
		ep.getInInterceptors().add(new LoggingInInterceptor());
		ep.getOutInterceptors().add(new LoggingInInterceptor());
	} */
	
	// 添加IN拦截器，实现对用户名密码的验证
	Server() {
		System.out.println("Starting Server...");
		MaiyoWs ws = new MaiyoWsImpl();
		EndpointImpl ep = (EndpointImpl) Endpoint.publish(SERVER_PORT, ws);
		ep.getInInterceptors().add(new AuthInterceptor());
	}
	
	public static void main(String[] args) {
		new Server();
		System.out.println("Server Ready...");
	}

}
